// firstPackage/pages/customManager/customFllow/customFllow.js
import { createFollowInfo } from '../../../../service/custom_service'

let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    themeStyle: "",
    followText: "",
    id: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id
    })
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
  },

  //确认提交跟进信息
  sureAction() {
    if (!this.data.followText) {
      wx.showToast({
        title: '请输入跟进内容',
        icon: "none"
      })
      return;
    }
    wx.showLoading();
    let obj = {
      content: this.data.followText,
      customerId: this.data.id
    }
    createFollowInfo(obj).then(res => {
      wx.hideLoading();
      if (res.code == 200) {
        wx.showToast({
          title: '添加成功',
          icon: "success"
        })
        setTimeout(() => {
          wx.navigateBack({
            delta: 0,
          })
        }, 2000);
      }
    }).catch(err => {
      console.log("JJLog:提交信息失败:" + JSON.stringify(err));
      wx.hideLoading();
      wx.showToast({
        title: '提交失败',
        icon: "none"
      })
    })
  },
  bindTextAreaBlur(e) {
    // console.log("JJLog:输入的内容是;" + JSON.stringify(e));
    this.setData({
      followText: e.detail.value
    })
    console.log("JJLog:当前跟进内容:" + this.data.followText);
  },



  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

 
})